package com.example.finalapplication;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class Calculation1 extends AppCompatActivity {
float rate=0f;
float result=0f;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculation1);
         Intent intent8 =getIntent();
         String Rate=intent8.getStringExtra("rate");
         String Name= intent8.getStringExtra("title");

          ((TextView) findViewById(R.id.title2)).setText(Name);
         String Rate1=Rate.substring(0,5);
         rate=Float.parseFloat(Rate1);

    }


    public void myClick(View btn) {
        EditText rmb = findViewById(R.id.yuan_inp);
        String str = rmb.getText().toString();


        if (str.length() == 0) {
            Toast.makeText(this, "请输入公斤数！", Toast.LENGTH_SHORT).show();
            return;
        } else {
            float i = Float.parseFloat(str);
            result = i * rate;
        }

        ((TextView) findViewById(R.id.result)).setText("需要：" + result+"元");
    }
}